//
//  SWSerialPortController.h
//  SerialPort
//
//  Created by MT-SW-003 on 2021/4/9.
//  Copyright © 2021 MT-SW-003. All rights reserved.
//

#import "SWSeilal.h"
#import "SWLoadConfig.h"
#import "SWSelectDevice.h"
#import "SWCheckData.h"

NS_ASSUME_NONNULL_BEGIN

@interface SWSerialPortController : NSObject
{
    int fd;
    id serialPort;
    id loadConfig;
    id check;
    id writeRead;
}

- (id)loadingConfigFile;

- (int)openSerialPort:(NSString *)devpath;

- (void)setSerialPortForDevice:(int)fd
                  withBaudRate:(int)baudRate
                   withDataBit:(int)dataBit
                   withStopBit:(int)stopBit
                    withParity:(char)parity;

- (ssize_t)writeData:(int)fd  withASCIIStr:(NSString *)writeStr;
- (ssize_t)writeData:(int)fd  withHEXStr:(NSString *)writeStr;

- (NSDictionary*)readData:(int)fd;

- (void)closeSerialPort:(int)fd;

- (NSArray*)deviceArray;

- (char *)chsToHex:(char*)chs;
- (char *)hexToChs:( char* )ascii;
@end

NS_ASSUME_NONNULL_END
